package com.shouhe.mysap.controller.plan;


import com.shouhe.mysap.common.MySapResult;
import com.shouhe.mysap.common.PageResult;
import com.shouhe.mysap.entity.PlanSaleOrder;
import com.shouhe.mysap.service.PlanSaleOrderService;
import com.shouhe.mysap.util.PageResultUtil;
import com.shouhe.mysap.util.UpdateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 守鹤
 * @since 2020-06-05
 */
@RestController
@RequestMapping("/plan-sale-order")
public class PlanSaleOrderController {

    @Autowired
    private PlanSaleOrderService planSaleOrderService;

    /**
     * @描述 得到供应链销售订单
     * @参数
     * @返回值
     */
    @RequestMapping("/getPlanOrderSales")
    public PageResult getPlanOrderSales(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
        PageResult pageResult = PageResultUtil.getPageResult(page, rows, planSaleOrderService);
        return pageResult;
    }


    /**
     * @描述 更新一个销售订单的状态, 通过id
     * @参数
     * @返回值
     */
    @RequestMapping("/updateSaleOrderStatusById")
    public MySapResult updateSaleOrderStatusById(Integer id, Integer status) {
        PlanSaleOrder saleOrder = new PlanSaleOrder().setId(id).setStatus(status);
        MySapResult result = UpdateUtil.updateObjectById("更新销售订单状态", saleOrder, planSaleOrderService);
        return result;
    }



}

